#ifndef RCVPKGUPDATE_H
#define RCVPKGUPDATE_H

#include "protocol.h"
#include "stream.h"
#include <list>
using namespace std;
class ZipFile;
class PathName;

class RecievePackageUpdate : public Protocol
{
	public:
		RecievePackageUpdate(Client*);
		~RecievePackageUpdate();

		bool8 recognize(uint8* Msg, uint32 Len);
		int32 start(uint8* Msg, uint32 Len);

		void netIn(int32 Amt);
		void netOut(int32 Amt);

        static void checkUploadDirectory();     // kharmon.  08-03-06.  Called by the "watch" thread to see if there 
                                                // are any files ready for upload in the "NewPackages" directory.

	protected:
		bool8 handleMessage(uint8* Msg, int32 len);
		bool8 remoteHostValid();
        
		static bool8 unzipPackage(PackageDescription *pkg);     
		static bool8 doUnzipPackage(ZipFile &ZF, PathName &Dest);

        // kharmon.  08-03-06.  Used by the "watch" thread to load packages from the "NewPackage" directory.
        static bool8 processPackage(const String& strPkgName, const String& strUserName, String& strExtractedPkgName);
        static bool8 addToDependencySortList(list<String>::iterator& currPos, list<String>& aFileList,list<String>& aSortedList);

	protected:
		pCStream	m_stream;
		String		m_zipname;
		String		m_username;
		int32		m_tosend;
		bool8		m_done;
		bool8		m_isRemoteHostValid;
		bool8		m_multibyte;

};

#endif
